<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAnnounceCateTable extends Migration
{
    /**
     * 创建公告分类表
     *
     * @return void
     */
    public function up()
    {
        Schema::create('announce_cate', function (Blueprint $table) {
            //表属性
            $table->engine = 'InnoDB';
            $table->charset = 'utf8';
            $table->collation = 'utf8_general_ci';
            //表字段
            $table->increments('id');
            $table->integer('pid')->default(0)->comment('公告分类父id');
            $table->string('name',45)->comment('公告分类名称');
            $table->string('description',45)->nullable()->comment('公告分类描述');

            $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'))->comment('创建时间');
            $table->timestamp('updated_at')->nullable()->comment('更新时间');
            $table->timestamp('deleted_at')->nullable()->comment('删除时间');
            //创建索引
            $table->unique('name');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('announce_cate');
    }
}
